package com.yan.yjhTest.reflection.genericCheck;

import java.lang.reflect.Method;
import java.util.ArrayList;

/**
 * 使用泛型越过泛型检查
 */
public class GenericCheckTest {
    public static void main(String[] args) throws Exception {
        ArrayList<String> strList = new ArrayList<String>();
        strList.add("aaa");
        strList.add("bbb");

        Class listClass = strList.getClass();

        //获取add()方法
        Method m = listClass.getMethod("add",Object.class);

        //调用add()方法
        m.invoke(strList,100);

        //遍历集合
        for (Object obj:strList) {
            System.out.println(obj);
        }

    }

}
